package cn.itcast.es.dao;

import cn.itcast.es.pojo.ESDemoBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

/**
 * Created by bothin
 * At 2020/4/2 9:54
 * Description:
 */
public interface ESDemoRepository extends ElasticsearchRepository<ESDemoBean,Long> {
    //默认的注释
    //@Query("{\"bool\" : {\"must\" : {\"field\" : {\"content\" : \"?\"}}}}")
    Page<ESDemoBean> findByContent(String content, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"field\" : {\"firstCode.keyword\" : \"?\"}}}}")
    Page<ESDemoBean> findByFirstCode(String firstCode, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"field\" : {\"secordCode.keyword\" : \"?\"}}}}")
    Page<ESDemoBean> findBySecordCode(String secordCode, Pageable pageable);
}
